<template>
  <!--渲染Echarts图表的容器-->
  <div id="aaa"></div>
</template>
<script>
// 引入Echarts
import * as echarts from "echarts";
import DateApi from "@/api/detailed/subject";
export default {
  // 属性
  data() {
    return {};
  },
  // 生命周期函数
  mounted() {
    this.initdata();
    this.initEcharts();
  },
  // 方法定义
  methods: {
    // 数据格式化
    // 渲染Echarts图表
    initdata() {},
    // 渲染Echarts图表
    initEcharts() {
      // 获取DOM元素（根据id）
      var chartDom = document.getElementById("aaa");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        title: {
          text: "Referer of a Website",
          subtext: "Fake Data",
          left: "center"
        },
        tooltip: {
          trigger: "item"
        },
        legend: {
          orient: "vertical",
          left: "left"
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "50%",
            data: [
              { value: 1048, name: "Search Engine" },
              { value: 735, name: "Direct" },
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)"
              }
            }
          }
        ]
      };

      option && myChart.setOption(option);
    }
  }
};
</script>

<style>
#aaa {
  width: 800px;
  height: 500px;
}
</style>